import type { BaiduPage } from './platform/baidu'
import type { BianPage } from './platform/bian'
import type { BingPage } from './platform/bing'
import type { GiteePage } from './platform/gitee'
import type { GithubPage } from './platform/github'
import type { GooglePage } from './platform/google'
import type { GreasyForkPage } from './platform/greasyfork'
import type { IconfontPage } from './platform/iconfont'
import type { SoPage } from './platform/so'
import type { SogouPage } from './platform/sogou'
import type { ZhiHuQuestionPage } from './platform/zhi_hu_question'
import { HOSTNAME, logger, SUPPORTED_PLATFORMS } from '../../types/constants'
import { SYMBOLS } from '../../types/interfaces'
import { BaiduPageType } from './platform/baidu/types'
import { BianPageType } from './platform/bian/types'
import { BingPageType } from './platform/bing/types'
import { GiteePageType } from './platform/gitee/types'
import { GithubPageType } from './platform/github/types'
import { GooglePageType } from './platform/google/types'
import { GreasyForkPageType } from './platform/greasyfork/types'
import { IconfontPageType } from './platform/iconfont/types'
import { SoPageType } from './platform/so/types'
import { SogouPageType } from './platform/sogou/types'
import { ZhiHuQuestionPageType } from './platform/zhi_hu_question/types'

// 页面类
export type PageTypeInstance
  = | GreasyForkPage
    | BaiduPage
    | GooglePage
    | BingPage
    | SogouPage
    | SoPage
    | IconfontPage
    | BianPage
    | ZhiHuQuestionPage
    | GiteePage
    | GithubPage
    | undefined

// 页面类型
export type PageType
  = | GreasyForkPageType
    | BaiduPageType
    | GooglePageType
    | BingPageType
    | SogouPageType
    | SoPageType
    | IconfontPageType
    | BianPageType
    | ZhiHuQuestionPageType
    | GiteePageType
    | GithubPageType
    | 'default'

// 未定义页面类型
export const UNDEFINED_PAGE_TYPE = 'undefined'
export const UNDEFINED_PAGE_TYPE_TIPS = '页面类型未定义'

// 获取当前平台的所有页面类型
export function getCurrentPlatformPageTypes(): PageType[] {
  switch (HOSTNAME) {
    case SUPPORTED_PLATFORMS.GREASY_FORK:
      return Object.values(GreasyForkPageType)
    case SUPPORTED_PLATFORMS.BAI_DU:
      return Object.values(BaiduPageType)
    case SUPPORTED_PLATFORMS.GOOGLE:
      return Object.values(GooglePageType)
    case SUPPORTED_PLATFORMS.BING:
      return Object.values(BingPageType)
    case SUPPORTED_PLATFORMS.SO_GOU:
      return Object.values(SogouPageType)
    case SUPPORTED_PLATFORMS.SO:
      return Object.values(SoPageType)
    case SUPPORTED_PLATFORMS.ICONFONT:
      return Object.values(IconfontPageType)
    case SUPPORTED_PLATFORMS.BIAN:
      return Object.values(BianPageType)
    case SUPPORTED_PLATFORMS.ZHI_HU_QUESTION:
      return Object.values(ZhiHuQuestionPageType)
    case SUPPORTED_PLATFORMS.GITEE:
      return Object.values(GiteePageType)
    case SUPPORTED_PLATFORMS.GITHUB:
      return Object.values(GithubPageType)
    default: {
      logger.info(`${SYMBOLS.STATUS.WARNING} 未定义页面类型，会影响主题获取，默认返回 'default'`)
      return ['default']
    }
  }
}
